/**
 * ==============================================
 * Created by Finger Technology.
 * Author: ZhiHuaWei <zhihua_wei@foxmail.com>
 * Date: 2019/8/24 15:07
 * Project: YunAdmin后台管理系统
 * Version: 1.0.0
 * Power: article.js
 * ==========================================
 */

KindEditor.ready(function (K) {
    window.editor = K.create('#content', {
        width: '75%',
        height: '250px',
        items: [
            'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
            'plainpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
            'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
            'superscript', 'clearhtml', '|', 'fullscreen', '/',
            'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
            'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
            'selectall', 'table', 'hr', 'emoticons', 'pagebreak',
            'anchor', 'link', 'unlink', '|', 'about'
        ]
    });
});

//表单提交验证
var Script = function () {

    'use strict';

    $.validator.setDefaults({
        submitHandler: function (form) {
            editor.sync()
            form.submit();
        }
    });

    $().ready(function () {
        $("#articleForm").validate({
            rules: {
                category_id: {
                    required: true
                },
                keywords: {
                    required: true
                },
                article_title: {
                    required: true
                },
                article_desc: {
                    required: true
                },
                content: {
                    required: true,
                },
            },

            messages: {
                category_id: "请选择文章分类",
                keywords: "请为分类输入简要关键字！",
                article_title: "请输入文章名称！！",
                article_desc: "请输入文档的简单摘要！",
                content: "请输入文章正文内容！"
            }
        });
    });

}();